<!DOCTYPE html >
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <!--
        /**
        * o------------------------------------------------------------------------------o
        * | This file is part of the RGraph package - you can learn more at:             |
        * |                                                                              |
        * |                          http://www.rgraph.net                               |
        * |                                                                              |
        * | This package is licensed under the RGraph license. For all kinds of business |
        * | purposes there is a small one-time licensing fee to pay and for non          |
        * | commercial  purposes it is free to use. You can read the full license here:  |
        * |                                                                              |
        * |                      http://www.rgraph.net/LICENSE.txt                       |
        * o------------------------------------------------------------------------------o
        */
    -->
    <title>RGraph: Javascript charts library - Annotating your charts</title>
    
    <meta name="keywords" content="rgraph html5 canvas chart docs annotating" />
    <meta name="description" content="RGraph: Javascript charts library - Documentation about annotating your charts" />
    
    <meta property="og:title" content="RGraph: Javascript charts library" />
    <meta property="og:description" content="A chart library based on the HTML5 canvas tag" />
    <meta property="og:image" content="http://www.rgraph.net/images/logo.png"/>

    <link rel="stylesheet" href="../css/website.css" type="text/css" media="screen" />
    <link rel="icon" type="image/png" href="../images/favicon.png">
    
    <!-- Place this tag in your head or just before your close body tag -->
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
    
    <script src="../libraries/RGraph.common.core.js" ></script>
    <script src="../libraries/RGraph.common.annotate.js" ></script>
    <script src="../libraries/RGraph.common.context.js" ></script>
    <script src="../libraries/RGraph.common.zoom.js" ></script>
    <script src="../libraries/RGraph.bar.js" ></script>
    <!--[if IE 8]><script src="../excanvas/excanvas.original.js"></script><![endif]-->
    
    <script>
        window.onload = function ()
        {
            bar = new RGraph.Bar('myBar', [[45,64],[32,51],[41,52],[54,43],[43,50]]);
            bar.Set('chart.title', 'An annotatable chart with context menu');
            bar.Set('chart.labels', ['John','Fred', 'Barry', 'Charlie', 'Joan']);
            bar.Set('chart.colors', ['red', 'blue']);
            bar.Set('chart.background.barcolor1', '#fff');
            bar.Set('chart.background.barcolor2', '#fff');
            bar.Set('chart.annotatable', true);
            bar.Set('chart.contextmenu', [['Show palette', RGraph.Showpalette], ['Clear', function () {RGraph.Clear(bar.canvas); bar.Draw();}]]);
            bar.Draw();
            
            RGraph.AddCustomEventListener(bar, 'onannotatestart', function (obj) {cl('Started annotating: ' + obj.id);});
            RGraph.AddCustomEventListener(bar, 'onannotate', function (obj) {cl('Annotating: ' + obj.id);});
            RGraph.AddCustomEventListener(bar, 'onannotateend', function (obj) {cl('Finished annotating: ' + obj.id);});
            RGraph.AddCustomEventListener(bar, 'onannotatecolor', function (obj) {cl('Changed annotate color: ' + obj.Get('chart.annotate.color'));});
            RGraph.AddCustomEventListener(bar, 'onannotateclear', function (obj) {cl('Fired the annotation clear event');});
        }
    </script>


    <script>
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-54706-2']);
      _gaq.push(['_trackPageview']);
    
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
</head>
<body>

    
    <!-- Social networking buttons -->
        <div id="social_icons" class="warning" style="border-radius: 10px; top: 1px; position: fixed; width: 140px; height: 20px">
            <a title="Bookmark with delicious" href="http://delicious.com/save?jump=close&v=4&noui&jump=close&url=http://www.rgraph.net&notes=RGraph%20is%20a%20HTML5%20based%20javascript%20charts%20library%20supporting%20a%20wide%20range%20of%20different%20chart%20types&title=RGraph:%20Javascript%20charts%20%26%20graph%20library" target="_blank"><img src="../images/delicious.png" alt="Bookmark with delicious" width="22" height="22" border="0" style="position: relative; top: 1px" /></a>
            <a href="http://www.twitter.com/_RGraph" target="_blank" title="Follow _RGraph on Twitter"><img src="../images/twitter.png" alt="Follow _RGraph on Twitter"/></a>
            <iframe src="http://www.facebook.com/plugins/like.php?app_id=253862424642173&amp;href=http%3A%2F%2Fwww.rgraph.net&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=21" scrolling="no" frameborder="0" style="width: 80px; height:21px; position: relative; top: 1px"></iframe>
        </div>
        
        <script>
            // Opera fix
            if (navigator.userAgent.indexOf('Opera') == -1) {
              document.getElementById("social_icons").style.position = 'fixed';
            }
        </script>
        
        <div id="google_plusone">
            <!-- Place this tag where you want the +1 button to render -->
            <g:plusone href="http://www.rgraph.net"></g:plusone>
        </div>
    <!-- Social networking buttons -->

    <div id="breadcrumb">
        <a href="../index.html">RGraph: Javascript charts library</a>
        >
        <a href="index.html">Documentation</a>
        >
        Annotating your charts
    </div>

    <h1>RGraph: <span>Javascript charts library</span> - Annotating your charts</h1>

    <script>
        if (RGraph.isIE8()) {
            document.write('<div style="background-color: #fee; border: 2px dashed red; padding: 5px"><b>Important</b><br /><br /> Internet Explorer 8 does not natively support the HTML5 canvas tag, so if you want to see the charts, you can either:<ul><li>Install <a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a></li><li>Use ExCanvas. This is provided in the RGraph Archive.</li><li>Use another browser entirely. Your choices are Firefox 3.5+, Chrome 2+, Safari 4+ or Opera 10.5+. </li></ul> <b>Note:</b> Internet Explorer 9 fully supports the canvas tag.</div>');
        }
    </script>

    <div style="float: right">
        <canvas id="myBar" width="400" height="200">[No canvas support]</canvas><br />
    </div>

    <p>
        The annotations feature brings presentation style functionality to RGraph charts. You can use this feature
        for highlighting your charts if you need to.
    </p>
    
    <ul>
        <li><a href="#how">How do annotations work?</a></li>
        <li><a href="#browser">Browser support</a></li>
        <li><a href="#what">What can I use annotations for?</a></li>
        <li><a href="#persistent">Are annotations persistent?</a></li>
        <li><a href="#palette">How do I show the mini-palette?</a></li>
        <li><a href="#clear">How can I clear the annotations?</a></li>
        <li><a href="#replay">Replaying annotations when they're off</a></li>
        <li><a href="#persist">Making your annotations persist</a></li>
    </ul>

    <a name="how"></a>
    <h4>How do annotations work?</h4>
    
    <p>
        Enabling annotations is a very simple affair, and consists of doing the following:
    </p>
    
    <pre class="code" style="width: 55%">myGraph.Set('chart.annotatable', true);</pre>

    <a name="browser"></a>
    <h4>Browser support</h4>

    <p>
        Annotations are supported in all browsers that RGraph works with - Firefox 3.5+, Chrome 2+, Safari 4+, Opera 10.5+ and
        MSIE/Google Chrome Frame. They DO NOT however work with MSIE 8/ExCanvas.
    </p>

    <a name="what"></a>
    <h4>What can I use annotations for?</h4>
    
    <p>
        As mentioned you can use it for presentations, highlighting things to yourself or others or just to have fun drawing (!).
    </p>
    
    <a name="persistent"></a>
    <h4>Are annotations persistent?</h4>
    
    <p>
        That depends on which browser you're using. The annotation data is stored in the users web browser (not on the web server),
        meaning currently (21st March 2010) browser support is limited to Firefox 3.5+, Safari 4+,
        Chrome 4+ and Opera 10.5+. MSIE 8 also has the required storage capabilities, but since it doesn't yet support canvas, the point is moot.
        The user does not have to
        confirm anything for storage to be allowed - try it out on this page by drawing on the chart and then refreshing the page.
    </p>
    
    <a name="palette"></a>
    <h4>How do I show the mini-palette?</h4>


    <p>
        You can show the palette by using the <i>RGraph.Showpalette</i> function shown below as a context menu item:
    </p>
    
    <pre class="code">
myObj.Set('chart.contextmenu', [
                                ['Show palette', RGraph.Showpalette],
                                ['Clear', function () {RGraph.Clear(myObj.canvas); myObj.Draw();}]
                               ]);
</pre>

    <p>
        This code will result in the same context menu as the chart above.
    </p>

    <a name="clear"></a>
    <h4>How can I clear the annotations?</h4>

    You can simply clear the chart and redraw it:
    
    <pre class="code">RGraph.Clear(myGraph.canvas); // Clear the chart
myGraph.Draw();               // Redraw it</pre>

    <p>
        In the chart above, there is a context menu that allows you to both clear the chart and also demonstrates the mini-palette
        feature available to you.
    </p>

    <a name="replay"></a>
    <h4>Replaying annotations when they're off</h4>    
        <p>
            When annotations are not enabled, any prior annotations that may have been made are not displayed. To show them you need
            to use the API function <i>RGraph.ReplayAnnotations(object)</i> after the call to .Draw().
        </p>
    
    <a name="persist"></a>
    <h4>Making your annotations persist  across browsers/computers</h4>
        <p>
            With a little bit of custom Javascript and some server side scripting you can make your annotations persist across
            different browsers/computers. You can find an example of this <a href="annotate_persist.html"><b>here</b></a>.
        </p>

</html>